﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MShop.Core.Domain.Trade>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="cphMeta" runat="server">
    <script type="text/javascript">
        window.history.forward(1); 
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm())
       { %>
    <div id="content" class="ovfl">
        <div>
            <img src='/images/step2.gif' />
        </div>
        <div class="cart">
            <fieldset>
                <legend>填写核对订单信息</legend>
                <div>
                    <div>
                        <div>
                            <h2>
                                收货人信息 <a href='#' style="display: none;" onclick="$('#divaddress').show();">(地址簿选择)</a>
                            </h2>
                            <table class="shipuser">
                                <tr>
                                    <td>
                                        所在地区：
                                    </td>
                                    <td>
                                        <%=Html.Partial("areacontrol", ViewData["area"] as MShop.Web.Models.SelectedAreaGroupModel)%>
                                        <%=Html.ValidationMessageFor(x => x.AreaId)%>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        详细地址：
                                    </td>
                                    <td>
                                        <%=Html.EditorFor(x=>x.Location) %>
                                        <%=Html.ValidationMessageFor(x => x.Location)%><em>*</em>格式：街道-小区-门牌号数-楼层-房间
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        邮政编码：
                                    </td>
                                    <td>
                                        <%=Html.EditorFor(x=>x.PostCode) %>
                                        <%=Html.ValidationMessageFor(x => x.PostCode)%><em>*</em>请填写正确的邮政编码
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        收 货 人：
                                    </td>
                                    <td>
                                        <%=Html.EditorFor(x=>x.ReceiverName) %>
                                        <%=Html.ValidationMessageFor(x=>x.ReceiverName) %><em>*</em>请填写您的有效证件上的真实姓名，以免延误您按时收到货物
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        联系手机：
                                    </td>
                                    <td>
                                        <%=Html.EditorFor(x=>x.Mobile) %>
                                        <%=Html.ValidationMessageFor(x => x.Mobile)%><em>*</em>联系手机和联系电话必须一项不能为空
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        联系电话：
                                    </td>
                                    <td>
                                        <%=Html.EditorFor(x=>x.Tel) %>
                                        <%=Html.ValidationMessageFor(x => x.Tel)%><em>*</em>
                                    </td>
                                </tr>                                
                            </table>
                            <div id="divaddress" style="display: none;">
                                <h2>
                                    地址簿
                                </h2>
                                <table>
                                    <tr>
                                        <td>
                                            <% ShopUsersAddress[] address = ViewData["address"] as ShopUsersAddress[];%>
                                            <ul>
                                                <% foreach (var item in address)
                                                   { %>
                                                <li>
                                                    <input type="radio" name="myaddress" value='<%=item.Id %>' /><%=item.Location %>
                                                </li>
                                                <%}%>
                                            </ul>
                                            <%=Html.ActionLink("创建地址","a") %>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div>
                           <span class="error"><%=Html.ValidationMessageFor(m => m.PayId)%></span>
                            <h2>
                                支付方式
                            </h2>
                            <% var pays = ViewData["pays"] as IEnumerable<Pay>; %>
                            <table width="100%">
                                <% foreach (var item in pays)
                                   { %>
                                <% if (item.PayType == "8" || item.PayType == "1") { }
                                   else
                                   { %>
                                <tr>
                                    <td class="r">
                                        <span>
                                            <input type="radio" name="payid" value='<%=item.Id %>' <%if(item.Id==Model.PayId) Response.Write("checked='checked'"); %> />
                                            <%=item.PayName %>
                                        </span>
                                        <% if (!string.IsNullOrEmpty(item.PayModel.Get("Logo").ToString())) Response.Write("<img align='middle' src='" + item.PayModel.Get("logo") + "' />");%>
                                    </td>
                                    <td class="r">
                                        <%=item.PayDesc %>
                                    </td>
                                </tr>
                                <%} %>
                                <%} %>
                            </table>
                        </div>
                        <div>
                         <span class="error"><%=Html.ValidationMessageFor(m=>m.DistributionId)%></span>
                            <h2>
                                配送方式
                            </h2>                           
                            <% var Distribution = ViewData["distributions"] as IEnumerable<Distribution>; %>
                            <table>
                                <tr>
                                    <th>
                                        配送名称
                                    </th>
                                    <th>
                                        配送费用
                                    </th>
                                    <th>
                                        配送说明
                                    </th>
                                </tr>
                                <% foreach (var item in Distribution)
                                   { %>
                                <tr>
                                    <td class="r">
                                        <span>
                                            <input type="radio" name="distributionid" onclick="getDistributePrice(<%=item.Id %>);"
                                                id="dist_<%=item.Id %>" <%if(item.Id==Model.DistributionId) Response.Write("checked='checked'"); %>
                                                value='<%=item.Id %>' />
                                        </span>
                                        <%=item.Name %>
                                        <img src='<%=item.logo %>' align="middle" />
                                    </td>
                                    <td>
                                        <span id="span_price_<%=item.Id %>">
                                            <%=item.Price%></span>
                                    </td>
                                    <td>
                                        <%=item.Desc %>
                                    </td>
                                </tr>
                                <%} %>
                            </table>
                        </div>
                        <div>
                         <span class="error"><%=Html.ValidationMessageFor(m =>m.DeliveryPeriodType)%></span>
                        <h2>
                         配送时间：
                        </h2> <%=Html.EditorFor(m=>m.DeliveryPeriodType,"DeliveryPeriod") %>
                          <%//=Html.Partial("trade/DeliveryPeriod") %>
                        </div>

                          
                                       
                                   
                        <div style="display: none;">
                            <h2>
                                发票信息
                            </h2>
                            <div>
                                <input type="radio" name="HasInvoice" checked="checked" value="False" />不需要
                                <input type="radio" name="HasInvoice" value="True" />需要 <span>发票抬头:<%=Html.EditorFor(x=>x.InvoiceName) %>
                                </span>
                            </div>
                        </div>
                        <div>
                            <h2>
                                订单备注
                            </h2>
                            如有需要，请输入你的订单备注。
                            <%=Html.EditorFor(x=>x.BuyerMemo) %>
                        </div>
                    </div>
                    <div>
                        <h2>
                            商品清单<span><%=Html.ActionLink("返回购物车修改", "mycart", "trade")%> </span>
                            
                        </h2>
                        <% var caritems = ViewData["CartItems"] as IEnumerable<CartItem>; %>
                        <table>
                            <tr>
                                <th>
                                    商品编号
                                </th>
                                <th>
                                    商品图片
                                </th>
                                <th>
                                    商品名称
                                </th>
                                <th>
                                    商城价
                                </th>
                                <th>
                                    赠送积分
                                </th>
                                <th>
                                    商品数量
                                </th>
                            </tr>
                            <% foreach (var item in caritems)
                               { %>
                            <tr>
                                <td>
                                    <%=item.ProductId %>
                                </td>
                                <td>
                                    <img class="thumb" src='<%=item.Product.ThumbImageUrl %>' />
                                </td>
                                <td>
                                    <%=item.ProductName %>
                                </td>
                                <td>
                                    <%=item.TotalPrice%>
                                </td>
                                <td>
                                    <%=item.Product.Points %>
                                </td>
                                <td>
                                    <%=item.Quanitiy %>
                                </td>
                            </tr>
                            <% } %>
                        </table>
                        <div>
                            <h2>
                                结算信息
                            </h2>
                            <ul>
                                <li>商品金额共计：<span  class="price"> ¥<%=(ViewData["totalfee"]) %></span>
                                </li>
                                <li>配送费用：<span  class="price">+<span id="distprice"><%=ViewData["distprice"] %></span></span> </li>
                                <li>支付费用：<span  class="price">+ ¥<span id="payprice">0.00</span></span> </li>
                                <li>订单折扣：<span  class="price"><span class="price">-¥<%=Model.DisCount %></span></span> </li>
                                <li>您需要为本订单支付：<span  class="price">¥<span class="price" id="payment"><%=Convert.ToDecimal(ViewData["totalfee"])+Convert.ToDecimal(ViewData["distprice"])  %></span></span>
                                </li>
                                <li>
                                 请核对以上信息，确认无误后点击：<input type="submit"  class="btn_login" value="提交订单" />
                                </li>
                            </ul>                            
                        </div>
                    </div>
                </div>
            </fieldset>
        </div>
    </div>
    <%} %>
</asp:Content>
<asp:Content ID="a" runat="server" ContentPlaceHolderID="cphFooter">
    <script type="text/javascript">
    var getDistributePrice = function (index) {
        var text = $('#span_price_' + index).text();
        $('#distprice').text(text);
        var value= parseFloat($('#distprice').text()) + <%=Convert.ToDecimal(ViewData["totalfee"])  %>;
         
        $('#payment').text((value.toFixed(2)));
    }
  
    </script>
</asp:Content>
